#ifndef MESSAGE_H_INCLUDED
#define MESSAGE_H_INCLUDED

#include <boost/shared_ptr.hpp>

using boost::shared_ptr;

namespace engine {

    namespace core {
        enum MessageTypes {
            MT_KILL_PROCESS = 0,
            MT_KEY_PRESS,
            MT_TERM_SIGNAL
        };

        struct KillProcessMessage {
            uint m_PID; //Process ID to kill
        };

        struct KeyPressMessage {
            uint m_Key;         //Key pressed
            uint m_State;
        };

		struct Message {
			uint	m_Type;
			uint  m_MsgDest; //0 = Registered processes, 1 = Kernel

			union {
                KillProcessMessage  kill;
                KeyPressMessage     key;
			};
			
			static shared_ptr<Message> createTermMessage() {
				shared_ptr<Message> newMessage(new Message());
				newMessage->m_Type = MT_TERM_SIGNAL;
				newMessage->m_MsgDest = 1; //Send to the kernel
				return newMessage;
			}
			
			static shared_ptr<Message> createKeyPressMessage(uint key, uint state=1) {
				shared_ptr<Message> newMessage(new Message());					
				newMessage->m_Type = MT_KEY_PRESS;
				newMessage->key.m_Key = key;
				newMessage->key.m_State = state;
				newMessage->m_MsgDest = 0; //Send to registered processes	
				return newMessage;
			}
		};
    }
}

#endif // MESSAGE_H_INCLUDED
